home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2590 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.7 KB

  1. Path: news.uoregon.edu!xmission!news
  2. From: tknarr@xmission.com  ( Todd Knarr )
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Quick and Dirty Date Function
  5. Date: 17 Jan 1996 02:32:22 GMT
  6. Organization: Chaos Central
  7. Message-ID: <4dhn3m$i57@news.xmission.com>
  8. References: <4dfatq$fec@news.pacifier.com>
  9. Reply-To: tknarr@xmission.com ( Todd Knarr )
  10. NNTP-Posting-Host: slc138.xmission.com
  11. X-Newsreader: IBM NewsReader/2 v1.2
  12.  
  13. In <4dfatq$fec@news.pacifier.com>, dgager@pacifier.com (Dave Gager) writes:
  14. > Does anybody know of, or have, a quick & dirty function that takes two 
  15. >dates and returns the EXACT number of days between them (inclusive). 
  16. >Preferrably, it should not need any maintenence after the year 2000, 
  17.  
  18. I don't know about quick-and-dirty, but I did come up with a class
  19. based on some routines for converting year/month/day to Julian day
  20. numbers. Once you've got Julian day numbers, the difference between
  21. them gives you the number of days between the two dates. I've checked
  22. them for sanity ( round-tripped every date and checked that the Julian
  23. day number for each date is one more than the Julian day number for
  24. the previous date ) over the range 1-Jan-4713BC through 31-Dec-9999AD.
  25.  
  26. The routines I used were courtesy of Eric Bergman-Terrell and appeared
  27. in the December 1990 issue of Computer Language. I can e-mail the class
  28. to you if you're interested, or post the class for dissection here ( the
  29. results will no doubt be messy <g> ).
  30.  
  31. --
  32. Todd Knarr : tknarr@xmission.com      |  finger for PGP public key
  33.                                       |  Member, USENET Cabal
  34.  
  35. Seriously, I don't want to die just yet.  I don't care how
  36. good-looking they are, I! don't! want! to! die!"
  37.                                         -- Megazone ( UF1 )
  38.  
  39.